package com.g.ocache;

import java.util.Map;

import com.g.ocache.event.StoreEventListener;


/**
 * 
 * @author Jingqi Xu
 */
public interface Store<K, V> {
	
	/**
	 * 
	 */
	boolean isRunning();
	
	void start() throws Exception;
	
	void stop() throws Exception;
	
	/**
	 * 
	 */
	int size();
	
	boolean containsKey(K key);
	
	void clear();
	
	V remove(K key);
	
	V get(K key);
	
	Map<K, V> getAll();

	V put(K key, V value);
	
	V putIfAbsent(K key, V value);
	
	Map<K, V> putAll(Map<K, V> values);
	
	/**
	 * 
	 */
	boolean addStoreEventListener(StoreEventListener<K, V> listener);
	
	boolean removeStoreEventListener(StoreEventListener<K, V> listener);
	
	/**
	 * 
	 */
	interface Factory<K, V> {
		
		Store<K, V> create(Cache<K, V> cache);
	}
}
